package com.wei.fallback;

import com.wei.entity.User;
import com.wei.remote.UserControllerRemoteClient;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserControllerRemoteFallbackFactory implements FallbackFactory<UserControllerRemoteClient> {
    @Override
    public UserControllerRemoteClient create(Throwable throwable) {
        throwable.printStackTrace();
        return new UserControllerRemoteClient(){
            @Override
            public User getOne() {
                User user = new User();
                user.setUsername("feign整合Hystrix处理异常");
                user.setPassword("feign整合Hystrix处理异常");
                return user;
            }

            @Override
            public String getValue() {
                return "feign处理异常";
            }
        };
    }
}
